﻿using System.Web;
using System.Web.SessionState;

namespace Sex
{
    public partial class Sex : System.Web.UI.Page
    {
        class ListSession : MyList
        {
            HttpSessionState s;
            string GetSessionKeys()
            {
                string KeyList = "";
                System.Collections.Specialized.NameObjectCollectionBase.KeysCollection Keys = s.Keys;
                foreach (string Key in Keys)
                {
                    KeyList += Key + " ";
                }
                return KeyList;
            }
            string GetSessionKeyValuePairs()
            {
                string KeyValueList = "";
                System.Collections.Specialized.NameObjectCollectionBase.KeysCollection Keys = s.Keys;
                foreach (string Key in Keys)
                {
                    KeyValueList +=  FormatMyKey(Key) + FormatMyText("=") + s[Key] + "<br/>";
                }
                return KeyValueList;
            }
            string GetSessionStaticObjects()
            {
                string StaticObjects = "";
                HttpStaticObjectsCollection hsoc = s.StaticObjects;
                foreach (string Key in hsoc)
                {
                    StaticObjects += hsoc[StaticObjects] + " ";
                }
                return StaticObjects;
            }
            string GetSessionContents()
            {
                string SessionContent = "";
                foreach (string Key in s.Contents)
                {
                    SessionContent += FormatMyKey(Key) + FormatMyText("=") + s.Contents[Key] + "<br/>";
                }
                return SessionContent;
            }
            public ListSession(State MyState) : base(MyState, "Session Object")
            {
                HttpContext myHttpContext = HttpContext.Current;
                s = myHttpContext.Session; 
                s.Add(strDemoVariableName, strDemoEntry);

                Add("s.CodePage", s.CodePage.ToString());
                Add("s.Contents", GetSessionContents());
                Add("s.CookieMode", s.CookieMode.ToString());
                Add("s.Count", s.Count.ToString());
                Add("s.IsCookieless", s.IsCookieless.ToString());
                Add("s.IsNewSession", s.IsNewSession.ToString());
                Add("s.IsReadOnly", s.IsReadOnly.ToString());
                Add("s.IsSynchronized", s.IsSynchronized.ToString());
                Add("s.Keys", GetSessionKeys());
                Add("s.Keys->Values", GetSessionKeyValuePairs());
                Add("s.LCID", s.LCID.ToString());
                Add("s.Mode", s.Mode.ToString()); 
                Add("s.SessionID", s.SessionID);
                Add("s.StaticObjects", GetSessionStaticObjects());
                Add("s.Timeout", s.Timeout.ToString());
            }
        }
    }
}